/*     */ package com.umeng.newxp.view;
/*     */ 
/*     */ import android.content.Context;
/*     */ import android.content.res.Resources;
/*     */ import android.text.SpannableString;
/*     */ import android.text.style.AbsoluteSizeSpan;
/*     */ import android.text.style.ForegroundColorSpan;
/*     */ import android.util.TypedValue;
/*     */ import android.view.LayoutInflater;
/*     */ import android.view.View;
/*     */ import android.view.ViewGroup;
/*     */ import android.view.ViewGroup.LayoutParams;
/*     */ import android.view.animation.Animation;
/*     */ import android.view.animation.AnimationUtils;
/*     */ import android.widget.AbsListView;
/*     */ import android.widget.AbsListView.OnScrollListener;
/*     */ import android.widget.ImageView;
/*     */ import android.widget.ListView;
/*     */ import android.widget.TextView;
/*     */ import android.widget.Toast;
/*     */ import com.umeng.common.Log;
/*     */ import com.umeng.common.b;
/*     */ import com.umeng.common.util.h;
/*     */ import com.umeng.common.util.j;
/*     */ import com.umeng.newxp.Promoter;
/*     */ import com.umeng.newxp.a.a;
/*     */ import com.umeng.newxp.common.ExchangeConstants;
/*     */ import com.umeng.newxp.common.g;
/*     */ import com.umeng.newxp.controller.ExchangeDataService;
/*     */ import com.umeng.newxp.controller.XpListenersCenter.AdapterListener;
/*     */ import com.umeng.newxp.controller.XpListenersCenter.InitializeListener;
/*     */ import com.umeng.newxp.net.XpReportClient;
/*     */ import com.umeng.newxp.net.e.a;
/*     */ import java.util.List;
/*     */ 
/*     */ public class EmbededContainer
/*     */ {
/*     */   private ViewGroup a;
/*     */   private ListView b;
/*     */   private Context c;
/*  50 */   public int mType = 8;
/*     */   private ExchangeDataService d;
/*     */   private List<Promoter> e;
/*     */   private XpListenersCenter.AdapterListener f;
/*  57 */   private int g = 5;
/*     */   private GridTemplateConfig h;
/*     */   private Animation i;
/*  62 */   private boolean j = false; private boolean k = false; private boolean l = false;
/*     */ 
/*     */   public EmbededContainer(Context paramContext, ViewGroup paramViewGroup, ListView paramListView, ExchangeDataService paramExchangeDataService, XpListenersCenter.AdapterListener paramAdapterListener, List<Promoter> paramList, GridTemplateConfig paramGridTemplateConfig)
/*     */   {
/*  68 */     if ((b.a(paramContext, "android.permission.ACCESS_NETWORK_STATE")) && 
/*  69 */       (!b.n(paramContext))) {
/*  70 */       Toast.makeText(
/*  71 */         paramContext, 
/*  72 */         paramContext.getResources().getString(
/*  73 */         com.umeng.common.a.c.a(paramContext)), 1)
/*  74 */         .show();
/*  75 */       return;
/*     */     }
/*  77 */     this.c = paramContext;
/*  78 */     this.h = paramGridTemplateConfig;
/*  79 */     this.f = paramAdapterListener;
/*     */ 
/*  81 */     if ((paramViewGroup == null) && (paramListView == null)) {
/*  82 */       Log.e(ExchangeConstants.LOG_TAG, 
/*  83 */         "this container integrated approach is failed! [view params neither ListView nor ViewGroup]");
/*  84 */       return;
/*     */     }
/*     */ 
/*  87 */     if (paramViewGroup != null) {
/*  88 */       this.l = true;
/*  89 */       this.a = paramViewGroup;
/*     */     } else {
/*  91 */       Log.e(ExchangeConstants.LOG_TAG, 
/*  92 */         "this container integrated approach is not support grid template!");
/*     */     }
/*  94 */     if (paramListView != null) {
/*  95 */       this.k = true;
/*  96 */       this.b = paramListView;
/*     */     } else {
/*  98 */       Log.e(ExchangeConstants.LOG_TAG, 
/*  99 */         "this container integrated approach is not support list template!");
/*     */     }
/* 101 */     paramExchangeDataService.layoutType = 8;
/* 102 */     this.d = paramExchangeDataService;
/*     */ 
/* 104 */     aI localaI = new aI(this.c, this.a);
/*     */ 
/* 106 */     if (paramExchangeDataService.show_progress_wheel) {
/* 107 */       localaI.a();
/*     */     }
/*     */ 
/* 110 */     r localr = new r(this, localaI);
/*     */ 
/* 117 */     if ((paramList != null) && (paramList.size() > 0)) {
/* 118 */       a(localaI, 1, paramList);
/* 119 */       Log.c(ExchangeConstants.LOG_TAG, "init view use setData.... " + paramList.size());
/* 120 */     } else if ((this.d.preloadData != null) && 
/* 121 */       (this.d.preloadData.a == a.a.a)) {
/* 122 */       List localList = this.d.preloadData.b();
/* 123 */       a(localaI, 1, localList);
/* 124 */       Log.c(ExchangeConstants.LOG_TAG, "init view use preloadData.... " + localList.size());
/*     */     } else {
/* 126 */       this.d.sessionId = "";
/* 127 */       this.d.requestDataAsyn(this.c, localr);
/* 128 */       Log.c(ExchangeConstants.LOG_TAG, "init view use server data.... ");
/*     */     }
/*     */   }
/*     */ 
/*     */   private void a(aI paramaI, int paramInt, List<Promoter> paramList)
/*     */   {
/* 134 */     if (this.d.initializeListener != null) this.d.initializeListener
/* 135 */         .onReceived(paramList == null ? 0 : paramList.size());
/* 136 */     if (paramaI != null) {
/* 137 */       paramaI.b();
/*     */     }
/* 139 */     if (paramInt == 0) {
/* 140 */       return;
/*     */     }
/* 142 */     this.e = paramList;
/* 143 */     setInteraction();
/*     */   }
/*     */ 
/*     */   public void setInteraction()
/*     */   {
/* 148 */     View localView = null;
/* 149 */     switch (this.d.getTemplate()) {
/*     */     case 1:
/* 151 */       if (this.l)
/* 152 */         localView = new GridTemplate(this.e, this.d, this.c, this.h).contentView;
/*     */       else
/* 154 */         new a(this.b, this.f);
/* 155 */       break;
/*     */     default:
/* 157 */       if (this.k)
/* 158 */         new a(this.b, this.f);
/*     */       else {
/* 160 */         localView = new GridTemplate(this.e, this.d, this.c, this.h).contentView;
/*     */       }
/*     */       break;
/*     */     }
/* 164 */     if (localView != null) {
/* 165 */       this.b.setVisibility(8);
/* 166 */       this.a.addView(localView);
/*     */     }
/*     */   }
/*     */ 
/*     */   private void a()
/*     */   {
/* 172 */     int m = ExchangeConstants.CONTAINER_LIST_COUNT > this.e.size() ? this.e.size() : 
/* 173 */       ExchangeConstants.CONTAINER_LIST_COUNT;
/* 174 */     ViewGroup.LayoutParams localLayoutParams = this.a.getLayoutParams();
/* 175 */     new j(this.c);
/* 176 */     int n = 
/* 177 */       j.a((ExchangeConstants.CONTAINER_HEIGHT + 1) * m);
/* 178 */     localLayoutParams.height = n;
/* 179 */     this.a.setLayoutParams(localLayoutParams);
/*     */   }
/*     */ 
/*     */   private class a {
/*     */     private d b;
/*     */     private View c;
/*     */     private TextView d;
/*     */     private ImageView e;
/*     */ 
/*     */     public a(ListView paramAdapterListener, XpListenersCenter.AdapterListener arg3) {
/* 192 */       a();
/*     */ 
/* 194 */       EmbededContainer.d(EmbededContainer.this).timeLine[2] = System.currentTimeMillis();
/* 195 */       this.c.setVisibility(0);
/* 196 */       EmbededContainer.c(EmbededContainer.this).addFooterView(this.c);
/*     */ 
/* 198 */       this.b = new s(this, EmbededContainer.c(EmbededContainer.this), EmbededContainer.b(EmbededContainer.this), 
/* 199 */         com.umeng.newxp.a.d.p(EmbededContainer.b(EmbededContainer.this)), false, EmbededContainer.e(EmbededContainer.this), 
/* 200 */         8, EmbededContainer.d(EmbededContainer.this));
/*     */       XpListenersCenter.AdapterListener localAdapterListener;
/* 216 */       if (localAdapterListener != null) this.b.a(localAdapterListener);
/*     */ 
/* 218 */       if (!ExchangeConstants.CONTAINER_AUTOEXPANDED) {
/* 219 */         EmbededContainer.g(EmbededContainer.this);
/*     */       }
/* 221 */       a locala = new a(EmbededContainer.d(EmbededContainer.this));
/* 222 */       if (EmbededContainer.c(EmbededContainer.this) != null) {
/* 223 */         EmbededContainer.c(EmbededContainer.this).setOnScrollListener(locala);
/* 224 */         EmbededContainer.d(EmbededContainer.this).page_index = 0;
/*     */       }
/*     */ 
/* 227 */       EmbededContainer.d(EmbededContainer.this).timeLine[3] = System.currentTimeMillis();
/*     */ 
/* 229 */       com.umeng.newxp.net.e locale = new e.a(EmbededContainer.b(EmbededContainer.this))
/* 230 */         .a(0).b(0)
/* 231 */         .d(EmbededContainer.d(EmbededContainer.this).getTimeConsuming())
/* 232 */         .d(EmbededContainer.h(EmbededContainer.this)).c(EmbededContainer.this.mType)
/* 233 */         .a((Promoter[])EmbededContainer.e(EmbededContainer.this).toArray(new Promoter[0]))
/* 234 */         .b(g.a(EmbededContainer.b(EmbededContainer.this), EmbededContainer.d(EmbededContainer.this))).a(EmbededContainer.d(EmbededContainer.this).slot_id).c(EmbededContainer.d(EmbededContainer.this).sessionId)
/* 235 */         .a();
/* 236 */       new XpReportClient(EmbededContainer.b(EmbededContainer.this)).sendAsync(locale, null);
/*     */     }
/*     */ 
/*     */     private void a() {
/* 240 */       LayoutInflater localLayoutInflater = (LayoutInflater)EmbededContainer.b(EmbededContainer.this)
/* 241 */         .getSystemService("layout_inflater");
/* 242 */       this.c = localLayoutInflater.inflate(com.umeng.newxp.a.d.q(EmbededContainer.b(EmbededContainer.this)), null);
/*     */ 
/* 244 */       this.d = ((TextView)this.c.findViewById(
/* 245 */         com.umeng.newxp.a.c.I(EmbededContainer.b(EmbededContainer.this))));
/*     */ 
/* 247 */       SpannableString localSpannableString = c();
/* 248 */       this.d.setText(localSpannableString);
/*     */ 
/* 250 */       this.e = ((ImageView)this.c.findViewById(com.umeng.newxp.a.c.z(EmbededContainer.b(EmbededContainer.this))));
/* 251 */       this.e.setVisibility(8);
/*     */ 
/* 253 */       EmbededContainer.a(EmbededContainer.this, AnimationUtils.loadAnimation(EmbededContainer.b(EmbededContainer.this), 
/* 254 */         com.umeng.newxp.a.a.d(EmbededContainer.b(EmbededContainer.this))));
/*     */     }
/*     */ 
/*     */     private void b()
/*     */     {
/* 289 */       t localt = new t(this);
/*     */ 
/* 348 */       EmbededContainer.d(EmbededContainer.this).pagination = true;
/* 349 */       if (EmbededContainer.d(EmbededContainer.this).page_index < 1) EmbededContainer.d(EmbededContainer.this).page_index = 1;
/* 350 */       EmbededContainer.d(EmbededContainer.this).page_index += 1;
/* 351 */       EmbededContainer.d(EmbededContainer.this).requestDataAsyn(EmbededContainer.b(EmbededContainer.this), localt);
/*     */     }
/*     */ 
/*     */     private SpannableString c() {
/* 355 */       String str = h.a();
/* 356 */       SpannableString localSpannableString = new SpannableString("更新于:     " + str);
/* 357 */       float f = TypedValue.applyDimension(2, 12.0F, EmbededContainer.b(EmbededContainer.this)
/* 358 */         .getResources().getDisplayMetrics());
/* 359 */       localSpannableString.setSpan(new AbsoluteSizeSpan((int)f), 4, localSpannableString.length(), 
/* 360 */         33);
/* 361 */       localSpannableString.setSpan(new ForegroundColorSpan(-7829368), 4, localSpannableString.length(), 
/* 362 */         33);
/* 363 */       return localSpannableString;
/*     */     }
/*     */ 
/*     */     private class a
/*     */       implements AbsListView.OnScrollListener
/*     */     {
/* 258 */       private boolean b = false;
/*     */ 
/*     */       public a(ExchangeDataService arg2)
/*     */       {
/*     */       }
/*     */ 
/*     */       public void onScroll(AbsListView paramAbsListView, int paramInt1, int paramInt2, int paramInt3)
/*     */       {
/* 266 */         if ((paramInt1 == 0) && (paramInt2 == paramInt3)) this.b = true;
/*     */         else
/* 268 */           this.b = false;
/*     */       }
/*     */ 
/*     */       public void onScrollStateChanged(AbsListView paramAbsListView, int paramInt)
/*     */       {
/* 273 */         if (!this.b) {
/* 274 */           if (EmbededContainer.a.a(EmbededContainer.a.this).getVisibility() != 0) {
/* 275 */             EmbededContainer.a.a(EmbededContainer.a.this).setVisibility(0);
/* 276 */             EmbededContainer.a.a(EmbededContainer.a.this).startAnimation(EmbededContainer.a(EmbededContainer.this));
/* 277 */             EmbededContainer.a.b(EmbededContainer.a.this).setText(com.umeng.newxp.a.e.g(EmbededContainer.b(EmbededContainer.this)));
/*     */           }
/*     */ 
/* 280 */           if ((Math.abs(EmbededContainer.c(EmbededContainer.this).getLastVisiblePosition() - EmbededContainer.c(EmbededContainer.this).getCount()) <= 2) && 
/* 281 */             (paramInt == 0))
/* 282 */             EmbededContainer.a.c(EmbededContainer.a.this);
/*     */         }
/*     */       }
/*     */     }
/*     */   }
/*     */ }

/* Location:           C:\Users\Administrator\Desktop\umeng_sdk.jar
 * Qualified Name:     com.umeng.newxp.view.EmbededContainer
 * JD-Core Version:    0.6.2
 */